/**
 * 
 */
package t4j.generics;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Queue;

import t4j.generics.coffee.Coffee;
import t4j.generics.coffee.CoffeeGenerator;
import t4j.net.mindview.util.Generator;


public class Generators {

	
	public static <T> Collection<T> fill(Collection<T> coll,Generator<T> gen,int n){
		
		for(int i = 0 ; i < n ; i++)
			coll.add(gen.next());
		
		return coll;
	}
	
	public static <T> Queue<T> fill(Queue<T> queue,Generator<T> gen,int n){
		
		for(int i = 0 ; i < n ; i ++)
			
			queue.add(gen.next());
		
		return queue;
	}
	
	public static <T> LinkedList<T> fill(LinkedList<T> list,Generator<T> gen,int n){
		
		for(int i = 0 ; i < n ; i++)
			
			list.add(gen.next());
		
		return list;
	}
	
	public static void main(String[] args) {
		
		System.out.println("-----------CoffeeGenerator-------");
		
		Collection<Coffee> coffee = fill(new ArrayList<Coffee>(), new CoffeeGenerator(),4);
		
		for(Coffee c : coffee)
			System.out.println(c);
		
		System.out.println("-----------Fibonacci------------");
		
		Collection<Integer> fnumbers = fill(new ArrayList<Integer>(),new Fibonacci(),12);
		
		for(int i : fnumbers)
			System.out.println(i + ", ");
		
		System.out.println("--------------Queue--------------");
		
		//Queue<Integer> queue = fill(new LinkedList<Integer>(),new Fibonacci(),12);
		
		  Queue<Integer> iQueue = fill( 
			      (Queue<Integer>)new LinkedList<Integer>(), 
			      new Fibonacci(), 12);
		
		for(int q : iQueue)
			System.out.println(q + ",");
		
		System.out.println("-------------LinkedList------------");
		
		LinkedList<Integer> list = fill(new LinkedList<Integer>(),new Fibonacci(),12 ) ;
		
		for(int i : list)
			System.out.println(i + ", ");
	}
}
